<template>
  <div>
    <div class="bigDiv">
      <div style="border-bottom: solid 0.2rem #f5f5f5">
        <a
          href="url"
          onclick="javascript:window.history.go(-1); return false;"
          style="position: absolute"
          ><img
            src="../../assets/goback.png"
            style="float: left; margin-top: 0.1rem"
        /></a>
        <p style="text-align: center; font-weight: 600; line-height: 1rem">
          推广客户
        </p>
      </div>
      <div class="search">
        <input
          class="s-input"
          v-model="keyword"
          @keydown="search"
          type="text"
          placeholder="搜索"
        />
      </div>
      <van-list
        v-model="loading"
        :finished="finished"
        finished-text="没有更多了"
        @load="onLoad"
      >
        <div class="big" v-for="(item, index) in list" :key="index">
          <div class="list">
            <div class="left">客户姓名</div>
            <div class="right">{{ item.name }}</div>
          </div>
          <div class="list">
            <div class="left">姓名拼音</div>
            <div class="right">{{ item.en_name }}</div>
          </div>
          <div class="list">
            <div class="left">手机号码</div>
            <div class="right">{{ item.mobile }}</div>
          </div>
          <div class="list">
            <div class="left">身份证号</div>
            <div class="right">{{ item.id_card }}</div>
          </div>
          <div class="list">
            <div class="left">预审额度</div>
            <div class="right">
              固定额度：{{ item.credit }}+专享额度：{{ item.exclusive_credit }}
            </div>
          </div>
          <div class="list">
            <div class="left">收件地址</div>
            <div class="right">{{ item.address }}</div>
          </div>
          <div class="list">
            <div class="left">申请时间</div>
            <div class="right">{{ item.create_time }}</div>
          </div>
        </div>
      </van-list>
    </div>
  </div>
</template>
<script>
import { customerList } from "@/api/index";
export default {
  data() {
    return {
      page: 0,
      keyword: "",
      last_page: 1,
      list: [],
      finished: false,
      loading: false,
    };
  },
  
  created() {
    // this.getList();
  },
  mounted() {},
  methods: {
    onLoad() {
    this.page = this.page + 1;
    this.getList();
  },
    search() {
      this.page = 0;
      this.list = [];
      this.onLoad();
    },
    getList() {
      customerList({ page: this.page, keyword: this.keyword }).then((res) => {
        this.loading=false
        if (res.code == 200) {
          console.log(res);
        
          this.last_page = res.data.last_page;
          if (this.page == 1) {
            this.list = res.data.data;
          } else {
            this.list = this.list.concat(res.data.data);
          }
          if (this.page >= this.last_page) {
            this.finished = true;
          }
        } else {
          this.finished = true;
          this.loading = false;
          this.$toast(res.msg);
          if(res.code==401){
            localStorage.clear()
            this.$router.replace('/login')
          }
        }
      });
    },
  },
};
</script>
<style scoped lang="scss">
@import "./index.scss";
</style>
